<h:panelGrid xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:t="http://myfaces.apache.org/tomahawk" width="100%">
	<p:panel id="pnlservice" style="border:none;">
		<h:inputHidden value="#{evokPatientTherapyBean.therapyService.id}" />
		<p:panelGrid style="width:100%" columns="2" columnClasses="width20,width80">
			<h:outputLabel value="#{msgs.default_name} *" />
			<p:selectOneMenu value="#{evokPatientTherapyBean.serviceId}" style="width:95%">
				<f:selectItem itemLabel="" itemValue="" />
				<f:selectItems value="#{evokPatientTherapyBean.serviceList}" var="en" itemLabel="#{en.name}"
					itemValue="#{en.id}" />
				<p:ajax update="priceunit,amount,total,unit,currency,currencyTotal"
					listener="#{evokPatientTherapyBean.serviceChange}" />
			</p:selectOneMenu>

			<h:outputLabel value="#{msgs.therapy_service_amount} *" />
			<h:panelGroup>
				<p:inputText value="#{evokPatientTherapyBean.therapyService.amount}" id="amount"
					label="#{msgs.therapy_service_amount}"
					style="validator:checkNotNull(#{msgs.therapy_service_amount})">
					<f:convertNumber pattern="#0.00" />
				</p:inputText>
				<h:outputText value="#{evokPatientTherapyBean.unit}" converter="enumConverter"
					enumName="TherapyUnit" id="unit" />
			</h:panelGroup>

			<h:outputLabel value="#{msgs.therapy_service_price} *" />
			<h:panelGroup columns="2">
				<p:inputText value="#{evokPatientTherapyBean.therapyService.priceUnit}" id="priceunit">
					<f:convertNumber pattern="#0.00" />
				</p:inputText>
				<h:outputText value="#{evokPatientTherapyBean.currency}" converter="enumConverter"
					enumName="TherapyServiceCurrency" id="currency" />
			</h:panelGroup>

			<h:outputLabel value="#{msgs.therapy_service_totalprice}" />
			<h:panelGroup>
				<p:inputText value="#{evokPatientTherapyBean.therapyService.priceTotal}" id="total">
					<f:convertNumber pattern="#0.00" />
				</p:inputText>
				<h:outputText value="#{evokPatientTherapyBean.currency}" converter="enumConverter"
					enumName="TherapyServiceCurrency" id="currencyTotal" />
			</h:panelGroup>
		</p:panelGrid>
	</p:panel>

	<h:panelGroup>
		<p:commandButton value="#{msgs.button_reset}" style="float:right;"
			icon="ui-icon-arrowreturnthick-1-s" actionListener="#{evokPatientTherapyBean.resetService}"
			update="pnlservice" />
			
		<p:commandButton value="#{msgs.button_submit}" style="float:right;" icon="ui-icon-disk"
			actionListener="#{evokPatientTherapyBean.submitService}" update="servicelist,pnlservice" />
	</h:panelGroup>

	<p:dataTable var="de" value="#{evokPatientTherapyBean.tsModel}" selectionMode="single"
		id="servicelist" widgetVar="wdgServiceList" rowIndexVar="ri" emptyMessage="">
		<p:ajax event="rowSelect" listener="#{evokPatientTherapyBean.selectTherapyService}"
			update=":mainform:tabviewTherapy:pnlservice" />

		<p:column headerText="#{msgs.table_index}">
			<h:outputText value="#{ri+1}" />
		</p:column>

		<p:column headerText="#{msgs.default_name}">
			<h:outputText value="#{de.service.name}" />
		</p:column>

		<p:column headerText="#{msgs.therapy_service_amount}" styleClass="right">
			<h:outputText value="#{de.amount} " stlyeClass="text-align:right;" />
			<h:outputText value="#{de.service.unit}" converter="enumConverter" enumName="TherapyUnit" />
		</p:column>

		<p:column headerText="#{msgs.therapy_service_price}" styleClass="right">
			<h:outputText value="#{de.priceUnit}" >
				<f:convertNumber pattern="#0.00" />
			</h:outputText>
			<h:outputText value="&#160;" escape="false"/>
			<h:outputText value="#{de.service.currency}" converter="enumConverter"
				enumName="TherapyServiceCurrency" />
		</p:column>

		<p:column headerText="#{msgs.therapy_service_totalprice}" styleClass="right">
			<h:outputText value="#{de.priceTotal}" >
				<f:convertNumber pattern="#0.00" />
			</h:outputText>
			<h:outputText value="&#160;" escape="false"/>
			<h:outputText value="#{de.service.currency}" converter="enumConverter"
				enumName="TherapyServiceCurrency" />
		</p:column>

		<p:column headerText="#{msgs.table_column_operation}">
			<p:commandLink oncomplete="confirmDeleteTherapyService.show()" style="float:right;"
				styleClass="ui-icon ui-icon-trash" title="#{msgs.button_delete}" type="image">
				<f:setPropertyActionListener value="#{de}" target="#{evokPatientTherapyBean.therapyService}" />
			</p:commandLink>
		</p:column>

		<p:columnGroup type="footer">
			<p:row>
				<p:column colspan="4" footerText="#{msgs.therapy_service_totalprice1}" style="text-align:right" />
				<p:column footerText="#{evokPatientTherapyBean.priceTotal}" style="text-align:right"/>
				<p:column footerText=""/>
			</p:row>
		</p:columnGroup>
	</p:dataTable>
</h:panelGrid>
